#pragma once
template <typename E,int M>
struct SqList
{
    E elem[M];
    int length;
};
template <typename E, int M>
void Initlist(SqList<E,M> &L)
{
    L.length = 0;
}
template <typename E,int M>
void ListInsert(SqList<E,M> &L,int i,E e)
{
    if (L.length == M)
       throw "L is full";
    if (i <1 || i> L.length + 1)
       throw "Invalid i";
    for (int j = L.length -1;j>=i-1;j--)
        L.elem[j+1]=L.elem[j];
    L.elem[i - 1] = e;
    L.length++;
}
template <typename E,int M>
void ListDelete(SqList<E,M> &L, int i,E &e)
{
    if (L.length == 0)
       throw "Invalid i";
    e = L.elem[i-1];
    for (int j = i; j < L.length; j++)
        L.elem[j-1]= L.elem[j];
    L.length--;
}